package com.zjfgz.lib_kt_com.user

import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
import androidx.navigation.fragment.findNavController
import com.zjfgz.lib_kt_com.R
import com.zjfgz.lib_kt_com.`fun`.toast
import com.zjfgz.lib_kt_com.base.BaseFragment
import kotlinx.android.synthetic.main.fragment_feed_back.*

class FeedBackFragment : BaseFragment() {

    override fun getLayout(): Int  = R.layout.fragment_feed_back

    override fun initView() {

        tv_commit.setOnClickListener {
            val content: String = et_content.text.toString()
            if (TextUtils.isEmpty(content)) {
                toast("请输入反馈意见")
                return@setOnClickListener
            }
            toast("已提交")
            findNavController().navigateUp()
        }
        et_content.addTextChangedListener(object : TextWatcher{
            override fun afterTextChanged(s: Editable?) {

            }

            override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {

            }

            override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
                tv_tip.text = s.toString().length.toString() + "/200"
            }
        })
    }

    override fun initSubScribe() {
    }
}